package org.example.erpapicommon.Util;

import java.util.ArrayList;
import java.util.List;

public class BasePage<T> implements Pageable<T> {
    private List<T> data;
    private int totalPage = 0;
    private int totalRow = 0;
    private int pageSize = 10;
    private int pageNumber = 1;

    public BasePage<T> setData(List<T> data) {
        this.data = data;
        return this;
    }

    public BasePage<T> setTotalPage(int totalPage) {
        this.totalPage = totalPage;
        return this;
    }

    public BasePage<T> setTotalRow(int totalRow) {
        this.totalRow = totalRow;
        return this;
    }

    public BasePage<T> setPageSize(int pageSize) {
        this.pageSize = pageSize;
        return this;
    }

    public BasePage<T> setPageNumber(int pageNumber) {
        this.pageNumber = pageNumber;
        return this;
    }

    public BasePage() {
        this.data = new ArrayList();
    }

    public BasePage(List<T> data) {
        this.data = data;
    }

    public BasePage(List<T> data, int pageNumber, int pageSize, int totalPage, int totalRow) {
        this.data = data;
        this.setPageNumber(pageNumber).setPageSize(pageSize).setTotalPage(totalPage).setTotalRow(totalRow);
    }

    public int getTotalRow() {
        return this.totalRow;
    }

    public int getTotalPage() {
        return this.totalPage;
    }

    public int getPageSize() {
        return this.pageSize;
    }

    public int getPageNumber() {
        return this.pageNumber;
    }

    public List<T> getList() {
        return this.data;
    }
}